resource "libvirt_volume" "cp-osdisk" {
  count = var.cp_node_count

  name             = format("${var.cluster_name}-cp%02d", count.index + 1)
  size             = 1024 * 1024 * 1024 * var.osdisk_size
  pool             = var.vm_pool
  base_volume_name = var.base_img
  base_volume_pool = var.base_pool
  format           = "qcow2"
}

resource "libvirt_volume" "work-osdisk" {
  count = var.work_node_count

  name             = format("${var.cluster_name}-work%02d", count.index + 1)
  size             = 1024 * 1024 * 1024 * var.osdisk_size
  pool             = var.vm_pool
  base_volume_name = var.base_img
  base_volume_pool = var.base_pool
  format           = "qcow2"
}

resource "libvirt_volume" "work-datadisk" {
  count = var.work_node_count

  name   = format("${var.cluster_name}-work%02d-data", count.index + 1)
  size   = 1024 * 1024 * 1024 * var.datadisk_size
  pool   = var.data_pool
  format = "raw"
}